    import axios from 'axios'
    import Vue from 'vue'
    import ElementUI from 'element-ui'
    import resource from 'vue-resource'
    import 'element-ui/lib/theme-chalk/index.css'
    //npm install element-ui
    Vue.use(resource)
    Vue.use(ElementUI)


    var vm = new Vue({
      el: '#app',
      data () {
          let cloud_uid = localStorage.getItem("cloud_uid")
          let cloud_pwd = localStorage.getItem("cloud_pwd")
          return {
               cloud_uid: cloud_uid,
               cloud_pwd: cloud_pwd
          }
    },
    created: function () {
      // let cloud_uid = localStorage.getItem("cloud_uid")
      // let cloud_pwd = localStorage.getItem("cloud_pwd")
      // if (typeof cloud_pwd != 'undefined' && cloud_pwd != '') {
      //   axios.post('/task/html/login', {
      //       uid: cloud_uid,
      //       pwd: cloud_pwd
      //     })
      //     .then(function (response) {
      //       if (response.status == 200) {
      //         if (response.data.code == 1) {
      //           window.location.href="/html/main.html"
      //         }
      //       }
      //       console.log(response);
      //     });
      // }
    },
    methods: {
        msgbox:function(msg){
          vm.$message({
                showClose: true,
                message: msg,
                type: 'error'
              });
        },
        reg_go: function(){
          window.location.href="/html/reg.html"
        },
        login_go: function () {
          axios.post('/task/html/login', {
            uid: this.cloud_uid,
            pwd: this.cloud_pwd
          })
          .then(function (response) {
            if (response.status == 200) {
              if (response.data.code == 1) {
                localStorage.setItem('cloud_uid', vm.cloud_uid)
                localStorage.setItem('cloud_pwd', vm.cloud_pwd);
                // 跳界面
                window.location.href="/html/main.html"
              }else{
                vm.msgbox('登录失败');
              }
            }
            console.log(response);
          })
          .catch(function (error) {
            vm.$message.error(error);
            console.log(error);
          });
        }
      }
    })
